from __future__ import print_function
from datetime import datetime
import sys

class Logger:
	verbose = False
	debugMode = False
	output = sys.stderr

	@staticmethod
	def init(args):
		Logger.verbose = args.verbose
		Logger.debugMode = args.debug

	@staticmethod
	def error(e):
		now = datetime.now().time().isoformat()
		print("{} ERROR {}: {}".format(now, e.__class__.__name__, str(e)), file = Logger.output)
		
	@staticmethod
	def info(msg):
		if not Logger.verbose:
			return
		now = datetime.now().time().isoformat()
		print("{} INFO {}".format(now, msg), end = "", file = Logger.output)
	
	@staticmethod
	def done():
		if not Logger.verbose:
			return
		print("done", file = Logger.output)
	
	@staticmethod
	def debug(desc, data):
		if not Logger.debugMode:
			return
		now = datetime.now().time().isoformat()
		print("{} DEBUG {}\n{}".format(now, desc, data), file = Logger.output)
		
	@staticmethod
	def message(msg):
		print(msg, file = sys.stdout)